package com.activenetwork.util;

import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter;

public class FileUtil {
	/**
	 * Create template file
	 * @param prefix
	 * @param suffix
	 * @param content
	 * @param directory
	 * @return
	 */
	public static File createTempFile(String prefix, String suffix, String content, File directory) {
		try {
			File f = new File(directory, prefix + "." +  suffix);
			f.createNewFile();
			PrintWriter pw = new PrintWriter(new FileOutputStream(f));
			pw.write(content);
			pw.flush();
			pw.close();
			return f;
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}
